{% extends template.self %}      
{% block book_sidebar %}
    <nav role="navigation" class="autoshow">
        <ul class="summary">
        <li><a href="https://www.sipeed.com" class="btn" target="_blank"><img src="/assets/icon_sipeed2.png" height="30" /></a></li>
        <li><a href="#" class="btn" onclick="toggleLanguage()">中文</a></li>
        {% for item in book.version %}
        {% if item.links %}
        <li class="version-link">
            <a href="#" class="btn" style="color:#444"></i>Version: <span style="font-weight: bold; display: inline">{{item.name}}</span></a>
            <ul class="hovershow">
                {% for entry in item.links %}
                <li><a href="{{entry.link}}" class="btn">Version: <span style="font-weight:bold; display: inline">{{entry.name}}</span></a></li>
                {% endfor %}
            </ul>
        </li>                
        {% else %}
        <li><a href="{{item.link}}" class="btn"></i>{{item.name}}</a></li>
        {% endif %}
        {% endfor %}         
        {% for item in book.items %}
        {% if item.links %}
        <li>
            <a href="#" class="btn"><i ></i>{{item.name}}</a>
            <ul>
                {% for entry in item.links %}
                <li><a href="{{entry.link}}" class="btn" target="_blank">{{entry.name}}</a></li>
                {% endfor %}
            </ul>
        </li>                
        {% else %}
        <li><a href="{{item.link}}" class="btn" target="_blank"><i></i>{{item.name}}</a></li>
        {% endif %}
    {% endfor %}      
        </ul>
    </nav>
    {{ super() }}
{% endblock %}
{% block javascript %}
    {{ super() }}
    <script type="text/javascript">
    function toggleLanguage () {
            var path = location.href;
            // console.log(path);
            if (path.indexOf('/zh') !== -1) {
                path = path.replace(/\/zh[\/$\s]/i, '/en/');
            } else if (path.indexOf('/en') !== -1) {
                path = path.replace(/\/en[\/$\s]/i, '/zh/');
            }
            // console.log('after: ' + path);    
            location.assign(path);
    }
    </script>
{% endblock %}